<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 500px;
            margin: 0 auto;
        }
        .active{
            background-color: blueviolet;
        }
        span{
            padding: 15px 20px;
        }
    </style>
</head>
<body>
    <div id="app" @click='change'>
        <span class="active">性别</span>
        <span>性格</span>
        <span>属性</span>
        <span>名称</span><br><br>
        <button @click.stop='queren'>确认</button>
        <span v-text='str'></span>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        let ve = new Vue({
            el: '#app',
            data:{
                str:''
            },
            methods:{
                change(event) {
                    event.target.classList.toggle('active')
                },
                queren(){
                   this.str = ''
                   let span =  document.querySelectorAll('.active')
                    for(var i=0;i<span.length;i++) {
                        this.str += span[i].innerHTML
                    }
                   console.log(span);
                }
            }

        })
    </script>
</body>
</html>